package com.ktjy.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktjy.dto.DictDataDTO;
import com.ktjy.mapper.SysDictDataMapper;
import com.ktjy.pojo.SysDictData;
import com.ktjy.service.SysDictDataService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDictDataServiceImpl implements SysDictDataService {

    @Resource
    SysDictDataMapper sysDictDataMapper;

    /**
     * 分页查询
     * @param sysDictData
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public IPage<SysDictData> getPage(SysDictData sysDictData, Integer pageNo, Integer pageSize) {
        //构造分页条件
        Page page=new Page(pageNo,pageSize);
        return sysDictDataMapper.getPage(page, sysDictData);
    }

    @Override
    public SysDictData getSysDictDataById(Long id) {
        return sysDictDataMapper.getById(id);
    }

    /**
     * 新增
     * @param sysDictData
     * @return
     */
    @Override
    public int insert(SysDictData sysDictData) {
        return sysDictDataMapper.insert(sysDictData);
    }

    /**
     * 修改
     * @param sysDictData
     * @return
     */
    @Override
    public int update(SysDictData sysDictData) {
        return sysDictDataMapper.updateById(sysDictData);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public int delete(Long id) {
        return sysDictDataMapper.deleteById(id);
    }

    @Override
    public Boolean deleteBatchIds(List<Long> ids) {
        return sysDictDataMapper.deleteBatchIds(ids)>0;
    }

    @Override
    public List<SysDictData> getDictData(DictDataDTO dictDataDTO) {
        return sysDictDataMapper.findDictData(dictDataDTO);
    }
}